/**
 * 防抖节流 -- 闭包基础
 */

function Debounce(callback, delay) {
    let timer = null
    return function () {
        if (timer) {
            clearTimeout(timer)
        }
        timer = setTimeout(() => {
            callback.apply(this, arguments)
        }, delay)
    }
}

function Throttle(callback, delay) {
    let curTime = Date.now()
    return function () {
        let nowTime = Date.now()
        if (nowTime - curTime >= delay) {
            callback.apply(this, arguments)
            curTime = Date.now()
        }
    }
}


